package com.study.spring.自定义注解;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Configuration
public class 简单注解 {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
        applicationContext.register(简单注解.class);
        applicationContext.refresh();
        UserService userService = applicationContext.getBean(UserService.class);
        userService.print();
    }

    @Target({ElementType.TYPE})
    @Retention(RetentionPolicy.RUNTIME)
    @Component
    public @interface MyComponent{
        String value() default "";
    }

    @MyComponent
    public class UserService{
        public void print(){
            System.out.println("userservice");
        }
    }
}
